/**
 * 跨域演示入口
 * @module index
 * @author its-wild
 * @date 2021/04/14
 */

$(function() {
    $('#btn').on('click', function() {
        $.ajax({
            url: 'http://localhost:9527/getData', // 如果直接访问接口就会产生跨域，报错 (Access to XMLHttpRequest at 'http://localhost:9527/getData' from origin 'http://0.0.0.0:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.)
            // url: '/api/getData', // '/api' 跨代理的标识，在 webpack.config.js 中配置
            success: function(res) {
                $('#main').text(res.data)
            }
        });
    });
});